<template>	
	<view class='pages'>			
		<!-- 二维码 -->
		<view class="qr-box">
			<canvas canvas-id="qrcode"  style="width: 300rpx;margin: 0 auto;"/>
			<view class="info">
				<u-alert-tips type="primary" :title="text1" ></u-alert-tips>
			</view>
			
		</view>		
						
	</view>		
</template>

<script>
	import uQRCode from '@/utils/uqrcode.js'
	export default {
		data() {
			return {				
				text1:'可以通行',
				foregroundColor:''
			}
		},
		onLoad() {
			if (this.text1 == '可以通行') {
				this.foregroundColor='#33CCFF'
			} else{
				this.foregroundColor='#FF0000'
			}
			this.qrFun(this.text1)
		},
		methods: {	
			
			//**生成二维码**//
			qrFun: function(text) {
				uQRCode.make({
					canvasId: 'qrcode',
					componentInstance: this,
					text: text,
					size: 150,
					margin: 0,
					backgroundColor: '#ffffff',
					foregroundColor: this.foregroundColor,
					fileType: 'jpg',
					errorCorrectLevel: uQRCode.errorCorrectLevel.H,
					success: res => {}
				})
			}
		}
	}
</script>

<style>	
	.pages {
		width: 98%;
		margin: auto;
		overflow: hidden;
	}	
	
	
	.qr-box {
		width: 400rpx;
		height: 460rpx;
		margin: 0 auto;
		margin-top: 200rpx;
	}
	.info{
		margin-top: 50rpx;
	}
</style>


